Add blank lines to break up chunks of code to make it easier to read
Increase code efficiency by merging multiple variables into one vector
When pulling data to be analysed, pull from public github so is easy for others to rerun scripts (use link)
| Code | Meaning |
|---|---|
+ |
Add |
- |
Subtract |
/ |
Divide |
* |
Multiply |
^ |
Power |
Inf |
Infinite |
NaN |
Not A Number |
NA |
Not Available |
c() |
Combine multiple variables into one vector |
[x] |
Pull out specific value from vector |
"" |
Create character vectors |
as.factor(x) |
Converts variable names into factors |
== |
Equal to |
!= |
Not equal to |
< |
Less than |
> |
More than |
<= |
Less than or equal to |
>= |
More than or equal to |
| |
Or |
%in% |
Within |
& |
To combine multiple logical operators |
$ |
To quick access data (our_data$Day) OR add column to data (our_data$location <- "United Kingdom") |
%>% |
Applies functions to data (my_data %>% function_1() %>% function_2()) |
Allows specifying multiple arguments within one custom made function if placed within {} brackets
mm <- function(x){
##sort vector from smallest to largest
##retrieve first and last value in vector
MINMAX <- sort(x)[c(1,length(x))]
##add `return()` to give wanted value
return(MINMAX)
}
To insert images you must have the image saved in same folder as RMarkdown file
<center>  </center>
<center> before centers the image/object and </center> after stops that